package com.freight.message.api.utils;

import com.freight.message.api.RemoteMessageClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

/**
 * message消息异步发送工具类
 */
@Component
@EnableAsync
public class MsgAsyncUtil {

    @Autowired
    private RemoteMessageClient remoteMessageClient;

    /**
     * 发送websocket通知公告消息（给所有客户端）
     * @return
     */
    @Async
    public void sendWsToAllNotice() {
        remoteMessageClient.sendWsToAllNotice();
    }

    /**
     * 发送websocket业务相关消息（给指定客户端）
     * @param userName
     * @param userName
     * @return
     */
    @Async
    public void sendWsToOneBusiness(String userName) {
        remoteMessageClient.sendWsToOneBusiness(userName);
    }

    /**
     * 发送企业微信通知
     * @param msg
     * @return
     */
    @Async
    public void sendWeChatMessage(String msg) {
        remoteMessageClient.sendWeChatMessage(msg);
    }

}
